package mk.edu.ii.navigatemacedonia;

import java.io.Serializable;

public class Site implements Serializable  {
	static private final long serialVersionUID = 42L;
	
	 private String SiteName;
	 private String SiteDescription;
	 private String SiteCategory;
	 private String SiteSubCategory;
	 private Float  SiteRating;
	 private String SiteImage;
	 private Double SiteLongitude;
	 private Double SiteLatitude;
	 private Float  SiteDistance;
	 private Float  SiteBearing;
	 
	 public Site(String siteName, String siteDescription, String siteCategory
			 , String siteImage, String siteLongitude, String siteLatitude
			 , String siteSubCategory, String siteRating)
	 {
		 this.SiteName = siteName;
		 this.SiteCategory = siteCategory;
		 this.SiteDescription = siteDescription;
		 this.SiteImage = siteImage;
		 this.SiteSubCategory = siteSubCategory;
		 
		 try{
			 this.SiteLatitude = Double.parseDouble(siteLatitude);
			 }
		 catch(NumberFormatException e){
			 this.SiteLatitude = -1d;
			 }
		 try{
			 this.SiteLongitude = Double.parseDouble(siteLongitude);
			 }
		 catch(NumberFormatException e){
			 this.SiteLongitude = -1d;
			 }
		 try{
			 this.SiteRating = Float.parseFloat(siteRating);
		 }
		 catch(NumberFormatException e){
			 this.SiteRating = -1f;
		 }
	 };
	 
	 public void setSiteDistance(Float distance){
		 this.SiteDistance=distance;
	 }
	 
	 public void setSiteBearing(Float bearing){
		 this.SiteBearing=bearing;
	 }
	 
	 public String getSiteName(){
		 return this.SiteName;
	 }
	 
	 public String getSiteDescription(){
		 return this.SiteDescription;
	 }
	 
	 public String getSiteCategory(){
		 return this.SiteCategory;
	 }
	 
	 public String getSiteImage(){
		 return this.SiteImage;
	 }
	 
	 public Double getSiteLatitude(){
		 return this.SiteLatitude;
	 }
	 
	 public Double getSiteLongitude(){
		 return this.SiteLongitude;
	 }
	 
	 public Float getSiteRating(){
		 return this.SiteRating;
	 }
	 
	 public String getSubCategory(){
		 return this.SiteSubCategory;
	 }
	 
	 public String getSiteDistance(){
		 
		 String d;
		 if(this.SiteDistance<1000)
			{
				d=String.valueOf(this.SiteDistance.intValue())+"m";
			}
			else{
				if(this.SiteDistance>500000){
					d=">500km";
				}else{
				d=String.valueOf(this.SiteDistance/1000);
				d=d.substring(0, d.indexOf(".")+2)+"km";
				}
			}
		 return d;
	 }
	 public Float getSiteDistanceF(){
		 return this.SiteDistance;
	 }
	 
	 public Float getSiteBearing(){
		 return this.SiteBearing;
	 }
	 
}
